background
A bit of background on why it presented itself.
- server vs. static
- tableau vs. html
approaches available today
References to approaches available today / packages
- echarts4r
- crosstalk
attempts
the 1st
The first ugly attempt
the second
An improved 2nd attempt
considerations / drawbacks
Speed / render / redraw
third attempt
Simplifying and finally cracking
tidy_employment_data <- fpp3::us_employment |>
janitor::clean_names() |>
as_tibble() |>
filter(!str_detect(title,":")) |>
rename(value = employed) |>
mutate(month = lubridate::as_date(month)) |>
group_by(title) |>
mutate(yoy = value/lag(value,12)-1,
`Three year comp` = value/lag(value,36)-1) |>
gather(key,value,value:`Three year comp`)
tidy_employment_data |>
mutate(month = datetime_to_timestamp(month)) |> # for highcharts date format
highcharter::hchart("line", highcharter::hcaes(month, value, name = title)) |>
hc_xAxis(type = "datetime") |>
add_multi_drop(
selectors = c("title", "key"),
selected = c("Total Private", "Three year comp")
)